<html>
<head><meta charset="utf-8"><title>Disable local thin LTO during rustc build · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Disable.20local.20thin.20LTO.20during.20rustc.20build.html">Disable local thin LTO during rustc build</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="226269033"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Disable%20local%20thin%20LTO%20during%20rustc%20build/near/226269033" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tyson Nottingham <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Disable.20local.20thin.20LTO.20during.20rustc.20build.html#226269033">(Feb 13 2021 at 21:38)</a>:</h4>
<p>Anyone know how I can turn off  local thin LTO during a stage0 rustc build, as in <code>./x.py build --stage 0 compiler/rustc</code>?  I've tried adding this to the root <code>Cargo.toml</code>, but to no avail:</p>
<div class="codehilite"><pre><span></span><code>[profile.release]
lto = &quot;off&quot;
</code></pre></div>
<p>Just wanting to do this for profiling purposes and my own edification.</p>



<a name="226269225"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Disable%20local%20thin%20LTO%20during%20rustc%20build/near/226269225" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Disable.20local.20thin.20LTO.20during.20rustc.20build.html#226269225">(Feb 13 2021 at 21:42)</a>:</h4>
<p>probably bootstrap is setting it:</p>
<div class="codehilite"><pre><span></span><code>$ rg lto src/bootstrap/
src/bootstrap/dist.rs
165:    let target_tools = [compiler, &quot;ld.exe&quot;, &quot;dlltool.exe&quot;, &quot;libwinpthread-1.dll&quot;];

src/bootstrap/builder.rs
1485:            let limit = match self.config.rust_thin_lto_import_instr_limit {

src/bootstrap/native.rs
201:        if builder.config.llvm_thin_lto {

src/bootstrap/config.rs
92:    pub llvm_thin_lto: bool,
135:    pub rust_thin_lto_import_instr_limit: Option&lt;u32&gt;,
413:    thin_lto: Option&lt;bool&gt;,
498:    thin_lto_import_instr_limit: Option&lt;u32&gt;,
769:            set(&amp;mut config.llvm_thin_lto, llvm.thin_lto);
804:                check_ci_llvm!(llvm.thin_lto);
828:            if config.llvm_thin_lto {
877:            config.rust_thin_lto_import_instr_limit = rust.thin_lto_import_instr_limit;
</code></pre></div>



<a name="226269982"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Disable%20local%20thin%20LTO%20during%20rustc%20build/near/226269982" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tyson Nottingham <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Disable.20local.20thin.20LTO.20during.20rustc.20build.html#226269982">(Feb 13 2021 at 21:58)</a>:</h4>
<p>Doesn't appear to be set in there. I'm probably misunderstanding how the Cargo.toml setting influences things between workspaces, dependencies, and so on.</p>



<a name="226271673"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Disable%20local%20thin%20LTO%20during%20rustc%20build/near/226271673" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> The 8472 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Disable.20local.20thin.20LTO.20during.20rustc.20build.html#226271673">(Feb 13 2021 at 22:10)</a>:</h4>
<p>maybe try the Cargo.toml for the rustc binary. I'm not sure if it works, it might complain due to workspaces but then should tell you where else to look</p>



<a name="226271791"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Disable%20local%20thin%20LTO%20during%20rustc%20build/near/226271791" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tyson Nottingham <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Disable.20local.20thin.20LTO.20during.20rustc.20build.html#226271791">(Feb 13 2021 at 22:11)</a>:</h4>
<p>Yeah, I was misunderstanding. <code>lto = "off"</code> applies to the workspace members, but not to the dependencies. Trying to disable it for dependencies in a <code>[profile.release.package."*"]</code> section yields:</p>
<div class="codehilite"><pre><span></span><code>`lto` may not be specified in a `package` profile
</code></pre></div>



<a name="226271847"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Disable%20local%20thin%20LTO%20during%20rustc%20build/near/226271847" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tyson Nottingham <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Disable.20local.20thin.20LTO.20during.20rustc.20build.html#226271847">(Feb 13 2021 at 22:12)</a>:</h4>
<p>So I had disabled local thin lto, just not to the degree I expected.</p>



<a name="226271875"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Disable%20local%20thin%20LTO%20during%20rustc%20build/near/226271875" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tyson Nottingham <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Disable.20local.20thin.20LTO.20during.20rustc.20build.html#226271875">(Feb 13 2021 at 22:13)</a>:</h4>
<p>But that's fine, disabling it for workspace members is good enough for my purposes. Thanks all.</p>



<a name="226272119"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Disable%20local%20thin%20LTO%20during%20rustc%20build/near/226272119" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tyson Nottingham <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Disable.20local.20thin.20LTO.20during.20rustc.20build.html#226272119">(Feb 13 2021 at 22:18)</a>:</h4>
<p>I don't quite understand yet why the lto setting in <code>[profile.release]</code> doesn't apply to dependencies while things like opt-level do though.</p>



<a name="226272971"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Disable%20local%20thin%20LTO%20during%20rustc%20build/near/226272971" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tyson Nottingham <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Disable.20local.20thin.20LTO.20during.20rustc.20build.html#226272971">(Feb 13 2021 at 22:40)</a>:</h4>
<p>I guess it makes sense for regular fat and thin LTO. Those would only be applied to the final binary, so it doesn't make sense to apply them to dependency crates.</p>
<p>But for local thin LTO, it does make sense to be able to apply it to dependency crates. So it may be considered a bug that <code>lto = "off"</code> doesn't disable it in dependencies. Or there's a hole in the configurability in not being able to set it to "off" in a package profile. Or both.</p>



<a name="226277159"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Disable%20local%20thin%20LTO%20during%20rustc%20build/near/226277159" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Disable.20local.20thin.20LTO.20during.20rustc.20build.html#226277159">(Feb 14 2021 at 00:29)</a>:</h4>
<p>Hm, I may have misunderstood something about how thin-local LTO works. I wasn't thinking it matters much for an rlib, but looking a little closer, it seems that it might.  Currently <code>lto="off"</code> is only passed to the final linking stage for a binary.  I'll need to investigate more, but thanks for bringing it up!</p>



<a name="226277534"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Disable%20local%20thin%20LTO%20during%20rustc%20build/near/226277534" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tyson Nottingham <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Disable.20local.20thin.20LTO.20during.20rustc.20build.html#226277534">(Feb 14 2021 at 00:41)</a>:</h4>
<p>Sure. I could also be totally misunderstanding the situation. :)</p>
<p>By the way, just created <a href="https://github.com/rust-lang/cargo/issues/9171">https://github.com/rust-lang/cargo/issues/9171</a></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>